package com.wht.media;

import cn.hutool.core.io.resource.ResourceUtil;
import org.noear.solon.Solon;
import org.noear.solon.annotation.SolonMain;
import org.noear.solon.core.handle.DownloadedFile;
import org.noear.solon.web.cors.CrossFilter;

import java.io.InputStream;

@SolonMain
public class App {
    public static void main(String[] args) {

        Solon.start(App.class, args, app -> {

            //跨域配置
            app.filter(-1, new CrossFilter().allowedOrigins("*"));

            //测试页面
            app.get("/", ctx -> ctx.forward("/index.html"));

            //文档页面
            app.get("/doc/api.html", ctx -> ctx.forward("/doc/api.html"));

            //postman接口文档json文件
            app.get("/postman", ctx -> {

                InputStream stream = ResourceUtil.getStream("static/doc/postman.json");
                ctx.outputAsFile(new DownloadedFile("", stream, "postman.json"));
            });
        });
    }
}